package com.jy.modules.cims.data.dao;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.jy.modules.cims.data.common.dto.TCMmCreditDealDetailDTO;
import com.jy.modules.cims.data.common.dto.TCMmCreditDetailDTO;
import com.jy.modules.cims.data.common.dto.TCMmCreditPackageDTO;
import com.jy.modules.cims.data.dto.CreditDetailDto;
import com.jy.modules.cims.data.dto.CreditPackageDto;
import com.jy.modules.cims.data.dto.credit.CreditTwoBuyMatchDto;
import com.jy.modules.cims.data.dto.credit.CreditTwoBuyRepayDto;
import com.jy.modules.cims.data.dto.credit.CreditTwoBuySettleDto;
import com.jy.modules.cims.data.dto.credit.SecondBuyCreditConfirmDto;
import com.jy.platform.core.mybatis.MyBatisRepository;

/**
 * 
 */
@MyBatisRepository
public interface CreditRightDao {

	/**
	 * @author zhiqiang
	 * @description: 更新对象T_C_MM_QUOTA_CREDIT_DETAIL
	 * @date 2015-01-12 20:34:29
	 * @param paramMap
	 */
	public void updateTCMmQuotaCreditDetailStatus(Map<String, Object> paramMap);

	/**
	 * @author zhiqiang
	 * @description: 更新对象T_C_MM_CREDIT_DETAIL
	 * @date 2015-01-12 20:34:29
	 * @param paramMap
	 */
	public void updateCreditDetailStatus(Map<String, Object> paramMap);

	/**
	 * 更新债权明细赎回占用状态
	 * 
	 * @Title updateCreditDetailStatusByCreditCode
	 * @Description TODO
	 * @param paramMap
	 *            void
	 * @author lizhiqiang
	 * @date 2015-5-10-下午4:31:58
	 * @update
	 * @throws
	 */
	public void updateCreditDetailStatusByCreditCode(Map<String, Object> paramMap);

	/**
	 * @author zhiqiang
	 * @description: 更新对象T_C_MM_QUOTA_CREDIT_DETAIL
	 * @date 2015-01-12 20:34:29
	 * @param paramMap
	 */
	public void updateTCMmQuotaCreditDetailStatusByTransferIds(Map<String, Object> paramMap);

	/**
	 * 
	 * @Title deleteTCMmCreditDealDetailByTransferIds
	 * @Description 删除交易流水明细表信息
	 * @param paramMap
	 *            void
	 * @author lizhiqiang
	 * @date 2015-1-23-下午3:44:26
	 * @update
	 * @throws
	 */
	public void deleteTCMmCreditDealDetailByTransferIds(Map<String, Object> paramMap);

	/**
	 * 
	 * @Title deleteTCMmCreditDealDetailByTransferIds
	 * @Description 删除
	 * @param paramMap
	 *            void
	 * @author lizhiqiang
	 * @date 2015-1-23-下午4:14:42
	 * @update
	 * @throws
	 */
	public void deleteTCMmCreditDetailByTransferIds(Map<String, Object> paramMap);

	/**
	 * @description 按照输入条件分页查询债权明细
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> searchCreditDetailForSettleByPaging(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件查询债权明细
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> getCreditDetailByUnequalCoreCreditStatus(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件查询债权明细
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> getQuotaCreditDetailByUnequalCoreCreditStatus(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件查询所有符合条件债权明细
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> searchCreditDetailForSettle(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件统计债权明细条数
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public Long getCreditDetailRowsForSettle(Map<String, Object> searchParams);

	/**
	 * @description 根据合作机构编号,债权包名称,合约编号，查询唯一一条债权包信息
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public TCMmCreditPackageDTO findCreditPackage(Map<String, Object> searchParams);
	
	/**
	 * @description 根据合作机构编号,债权包名称,合约编号，查询配置二次购买的债权包信息
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<CreditPackageDto> searchCreditPackageForSecondCode(Map<String, Object> searchParams);

	/**
	 * @description 根据结算流水号查询二次购买的流水号
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 * @return
	 */
	public List<String> getSecondBuyDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description 根据交易流水号删除合作机构交易流水表 T_C_MM_COOPERORG_DEAL
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCooperorgDealByDealCode(Map<String, Object> searchParams);

	/**
	 * @description:根据交易流水号删除 债权交易流水表明细 T_C_MM_CREDIT_DEAL_DETAIL
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCreditDealDetailByDealCode(Map<String, Object> searchParams);

	/**
	 * @description:根据交易流水号删除 债权交易流水表明细 T_C_MM_CREDIT_DETAIL
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCreditDetailByDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description:根据交易流水号删除 二次购买关联的交易流水表 T_C_MM_COOPERORG_DEAL_RELE
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCooperorgDealReleByDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description:根据交易流水号删除 结算计划表 T_C_MM_COST_PLAN
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCostPlanByDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description:根据交易流水号删除 还款计划表 T_C_MM_REFUND_PLAN
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteRefundPlanByDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description:根据交易流水号删除 客户信息表 T_C_MM_CUSTINFO
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteCustInfoByDealCode(Map<String, Object> searchParams);
	
	/**
	 * @description:删除无效的债权明细 T_C_MM_CREDIT_DETAIL
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteInvalidCreditDetail(Map<String, Object> searchParams);
	
	/**
	 * @description:删除无效的债权流水 T_C_MM_CREDIT_DEAL_DETAIL 
	 * @author shengzhoutao
	 * @date 2015-01-07 16:21:57
	 * @param searchParams
	 */
	public void deleteInvalidCreditDeal(Map<String, Object> searchParams);
	
	/**
	 * @description 修改剩余还款期数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailResidueRepayPeriod(Map<String, Object> searchParams);

	/**
	 * @description 批量修改债权明细状态
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailStatusByCreditorDetailIdList(Map<String, Object> searchParams);

	/**
	 * @description 批量修改债权明细状态
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailStatusByTransferIdList(Map<String, Object> searchParams);

	/**
	 * @description 批量修改债权明细的剩余还款期数减一，关联结算计划，剩余未结算的期数。
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailResidueRepayPeriodForSettle(Map<String, Object> searchParams);
	
	/**
	 * 批量插入债权交易明细
	 * 
	 * @Title insertCreditDealDetailByBatch
	 * @Description TODO void
	 * @author lizhiqiang
	 * @date 2015-4-18-下午2:39:56
	 * @update
	 * @throws
	 */
	public void insertCreditDealDetailByBatch(List<TCMmCreditDealDetailDTO> dlist);

	/**
	 * 批量插入债权明细
	 * 
	 * @Title insertCreditDealDetailByBatch
	 * @Description TODO void
	 * @author lizhiqiang
	 * @date 2015-4-18-下午2:39:56
	 * @update
	 * @throws
	 */
	public void insertCreditDetailByBatch(List<TCMmCreditDetailDTO> dlist);

	/**
	 * @description 查询交易流水下的债权价值
	 * @param searchParams
	 * @return
	 */
	public BigDecimal getSumThisMakeCreditValueByDealCode(Map<String, Object> searchParams);

	/**
	 * @description 据交易流水号查询生成结算计划不同的转让编号的个数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public Long getDistinctTransferIdCountForCostPlan(Map<String, Object> searchParams);

	/**
	 * @description 根据交易流水号查询债权明细不同的转让编号的个数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public Long getDistinctTransferIdCountForCreditDetail(Map<String, Object> searchParams);
	/**
	 * @description 查询二次购买需要确认的债权列表
	 * @Title getSecondBuyCreditConfirm
	 * @Description TODO
	 * @param dealDto
	 * @return 
	 * List<SecondBuyCreditConfirmDto> 
	 * @author lizhiqiang
	 * @date 2015-9-23-上午10:06:38
	 * @update 
	 * @throws
	 */
	public List<SecondBuyCreditConfirmDto> getSecondBuyCreditConfirm(Map<String, Object> paramMap);

	/**
	 * @description 查询符合结算条件的债权包
	 * @author shengzhoutao
	 * @param paramMap
	 * @return
	 */
	public List<CreditPackageDto> searchCreditPackageForSettle(Map<String, Object> paramMap);
	
	/**
	 * @description 根据结算条件修改债权明细状态
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailStatusForSettle(Map<String, Object> paramMap);
	
	/**
	 * @description 月还重置债权信息：修改债权状态已转让, 修改剩余还款期数减一 
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCreditDetailForResetSettle(Map<String, Object> paramMap);
	
	/**
	 * @description 月还重置结算计划信息：修改结算状态未结算
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public int updateCostPlanForResetSettle(Map<String, Object> paramMap);
	
	/**
	 * 根据交易流水号
	 * @Title updateCreditDealDetailCautionMoney
	 * @Description TODO
	 * @param paramMap 
	 * void 
	 * @author lizhiqiang
	 * @date 2016-4-15-下午3:53:45
	 * @update 
	 * @throws
	 */
	public void updateCreditDealDetailCautionMoney(Map<String, Object> paramMap);
	/**
	 * 查询待结算的债权明细
	 * @Title getDealDetailListByDealcode
	 * @Description TODO
	 * @param paramMap
	 * @return 
	 * List<CreditDetailDto> 
	 * @author lizhiqiang
	 * @date 2016-4-18-下午3:59:56
	 * @update 
	 * @throws
	 */
	public List<CreditDetailDto> getDealDetailListByDealcode(Map<String, Object> paramMap);
	/**
	 * 更新结算状态
	 * @Title updateCreditDealDetailCostState
	 * @Description TODO
	 * @param paramMap 
	 * void 
	 * @author lizhiqiang
	 * @date 2016-4-19-上午11:14:23
	 * @update 
	 * @throws
	 */
	public void updateCreditDealDetailCostState(Map<String, Object> paramMap);
	/**
	 * 更新结算状态
	 * @Title updateCreditDealDetailCostState
	 * @Description TODO
	 * @param paramMap 
	 * void 
	 * @author lizhiqiang
	 * @date 2016-4-19-上午11:14:23
	 * @update 
	 * @throws
	 */
	public void updateCooperorgDealCostState(Map<String, Object> paramMap);
	
	
	
	/**
	 * @description 查询还款计划的条数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public Long getRefundPlanRows(Map<String, Object> searchParams);
	
	/**
	 * @description 查询符合生成还款计划和结算计划的债权明细
	 * @author shengzhoutao
	 * @param paramMap
	 * @return
	 */
	public List<CreditDetailDto> searchCreditDetailForCreatPlan(Map<String, Object> paramMap);
	
	/**
	 * @description 查询符合生成还款计划和结算计划的债权明细条数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public Long getCreditDetailCountForCreatPlan(Map<String, Object> paramMap);
	
	/**
	 * *************************************************二次购买plus
	 */
	/**
	 * 二次购买--正常月还
	 * @Description 
	 * @param paramMap
	 * @author zhangmi
	 * @date 2016-4-25
	 */
	public List<CreditTwoBuyRepayDto> getCreditTwoBuyRepayList(Map<String, Object> paramMap);
	
	/**
	 * 二次购买--提前结清
	 * @Description 
	 * @param paramMap
	 * @author zhangmi
	 * @date 2016-4-25
	 */
	public List<CreditTwoBuySettleDto> getCreditTwoBuySettleList(Map<String, Object> paramMap);
	
	/**
	 * 二次购买--新匹配债权
	 * @Description 
	 * @param paramMap
	 * @author zhangmi
	 * @date 2016-4-25
	 */
	public List<CreditTwoBuyMatchDto> getCreditTwoBuyMatchList(Map<String, Object> paramMap);
	
	public void updateCreditDetailCreditorStatus(Map<String, Object> paramMap);
	
	/**
	 * @description 按照输入条件，查询所有符合结算交易，并且标志上需要结算的不同机构编号
	 * @author shengzhoutao
	 * @date 2016-04-23 
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> searchSettleCooperorgCode(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件，分页查询所有符合结算交易，并且标志上需要结算的债权明细
	 * @author shengzhoutao
	 * @date 2016-04-23 
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> searchSettleCreditDetail(Map<String, Object> searchParams);

	/**
	 * @description 按照输入条件，查询所有符合结算交易，并且标志上需要结算的债权明细的条数
	 * @author shengzhoutao
	 * @param searchParams
	 * @return
	 */
	public Long getSettleCreditDetailRows(Map<String, Object> searchParams);
	
	/**
	 * @description 自动月还结算交易后，并且标志上需要结算,月还结算确认:修改流水表结算状态和申请编号 
	 * @author shengzhoutao
	 * @param creditDetailDtoList
	 */
	public void updateCreditDetailCostInfo(List<CreditDetailDto> creditDetailDtoList);
	
	/**
	 * @description 自动月还结算交易后，并且标志上需要结算,月还结算确认:修改流水表接口编号
	 * @author shengzhoutao
	 * @param creditDetailDtoList
	 */
	public void updateCreditDetailInferfaceNo(List<CreditDetailDto> creditDetailDtoList);
	
	
	/**
	 * @description 
	 * @author shengzhoutao
	 * @param searchParams
	 */
	public void updateCreditDealDetailCostInfo(Map<String, Object> searchParams);
	
	/**
	 * @description 终止核心提前结清，合作机构未结清历史债权明细
	 * @author shengzhoutao
	 * @param searchParams
	 */
	public void endCreditDetailForHistorySettle(Map<String, Object> searchParams);
	
	/**
	 * @description 终止结算计划全部已经结清，债权明细债权状态不正确数据
	 * @author shengzhoutao
	 * @param searchParams
	 */
	public void endCreditDetailForAllSettle(Map<String, Object> searchParams);
	
	/**
	 * @description 终止赎回两边系统状态不一致的历史债权明细 
	 * @author shengzhoutao
	 * @param searchParams
	 */
	public void endCreditDetailForHistoryRedeem(Map<String, Object> searchParams);
	
	
	public List<TCMmCreditPackageDTO> getContractCodeBySecondCode(String contractCode);
	
	/**
	 * 
	 * @Title getContractCodeBySecondCode
	 * @Description TODO
	 * @param contractCode
	 * @return 
	 * List<TCMmCreditPackageDTO> 
	 * @author lizhiqiang
	 * @date 2016-7-20-上午10:19:36
	 * @update 
	 * @throws
	 */
	public List<String> getDealCodeTypeBySecondCode(String dealCode);
	
	/**
	 * @description 按照二次购买流水号，查询所有符合需要结算的虚拟月还的债权明细
	 * @author shengzhoutao
	 * @date 2016-04-23 
	 * @param searchParams
	 * @return
	 */
	public List<CreditDetailDto> searchVrSettleCreditDetail(Map<String, Object> searchParams);
	
	/**
	 * 
	 * @Description 根据二次购买流水号获取，结算编号，结算状态，结算日期
	 * @param searchParams
	 * @return   
	 * List<CreditDetailDto>  
	 * @throws
	 * @author zhangmi
	 * @date 2016-7-18
	 */
	public List<CreditDetailDto> getSecondSettleApplyIdByDealCode(Map<String, Object> searchParams);
	
	/**
	 * 
	 * @Description 查询账单日需要预留的债权
	 * @param searchParams
	 * @return   
	 * List<CreditDetailDto>  
	 * @throws
	 * @author 
	 * @date 
	 */
	public List<CreditDetailDto> getReservationCreditForSettle(Map<String, Object> searchParams);
}